package com.springweb.unit7.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

@Controller
@RequestMapping(value="fileUpload")
public class FileUploadController {
	
	/**
	 * 
	 * Description: 跳转到文件上传表单页面
	 *
	 * @return
	 * @Author zhangxujun
	 * @Create Date: 2017年11月16日 下午5:33:14
	 */
	@RequestMapping(value="fileUploadForm", method=RequestMethod.GET)
	public String fileUploadForm() {
		return "unit7/fileUploadForm";
	}
	
	/**
	 * 
	 * Description: 文件上传
	 *
	 * @return
	 * @Author zhangxujun
	 * @Create Date: 2017年11月16日 下午5:50:41
	 */
	@RequestMapping(value="fileUpload", method=RequestMethod.POST)
	// @RequestPart("profilePicture") byte[] profilePicture
	// @RequestPart("profilePicture") Part profilePicture (必须支持Servlet3.0包括tomcat)
	public String fileUpload(@RequestPart("profilePicture") MultipartFile profilePicture) {
		System.out.println(profilePicture.getOriginalFilename());
		return "unit7/fileUploadForm";
	}
}
